package com.ml.mall.mapper.product;

import com.ml.mall.bean.req.product.SysProductQueryPageReq;
import com.ml.mall.bean.req.shop.ShopSupplierQueryDto;
import com.ml.mall.bean.res.product.SysProductQueryPageRes;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ml.mall.bean.res.shop.ShopSupplierQueryRes;
import com.ml.mall.entity.product.SysProduct;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author kyyang
* Created 2021-05-15
*/
@Repository
public interface SysProductMapper extends BaseMapper<SysProduct> {



    /**
     * @description: 分页查询产品信息
     * @author kyyang
     * @date 2021/5/15 19:26
     * @version 1.0
     */
    List<SysProductQueryPageRes> selectSysProductByPage(@Param("dto") SysProductQueryPageReq sysProductQueryPageReq);


    /**
     * @description    :分页查询商店卖家
     * @author         :zxm
     * @date           :2021/5/26
     **/
    List<ShopSupplierQueryRes> selectPageShopSupplier(@Param("dto") ShopSupplierQueryDto dto);

    /**
     * @description    :分页查询商店卖家的总条数
     * @author         :zxm
     * @date           :2021/5/26
     **/
    Long countShopSupplier(@Param("dto")ShopSupplierQueryDto dto);

    /**
     * @description    :查询卖家产品最多的五个目录
     * @author         :zxm
     * @date           :2021/5/27
    **/
    List<String> selectSupplierCategory(@Param("companyId")Long companyId);

    /**
     * @description    :查询产品index最小的图片地址
     * @author         :pl
     * @date           :2021/6/25
     **/
    @Select("select pic_url from sys_product_variant_pic where product_id = #{productId} order by `index` limit 1")
    String selectPicUrlForProductShopPage(@Param("productId") long productId);

    /**
     * @description    :查询产品对应的品牌信息
     * @author         :pl
     * @date           :2021/6/25
     **/
    @Select("select brand from sys_product where product_id = #{productId}")
    String selectBrandForProductShopPage(@Param("productId") long productId);

}
